package Method;

/**
 * ClassName:MethodDemo13
 * Package:Method
 * Description:
 *
 * @Author:ZhangXin
 * @Create2023/1/12-13:08
 * @Version:v1.0
 */
public class MethodDemo13 {
    /*
    * 基本数据类型：数据值是存储在自己的空间中
    * 特点：(赋值给其他变量,也是赋的真实值)
    *
    * 引用数据类型：数据值是存储在其他空间中,子控件中存储的是地址值
    * 特点：(赋值给其他变量,赋的地址值)*/
    public static void main(String[] args) {
        int []arr={1,2,3,4,5,6,7,8,9};
        int[] copyArr = copyOfRange(arr, 0, 5);
        for (int i = 0; i < copyArr.length; i++) {
            System.out.print(copyArr[i]+" ");
        }
    }
    public static int[] copyOfRange(int[]arr,int from,int to){
        int [] newArr=new int[to - from];
        int index=0;
        for (int i = from; i < to; i++) {
            newArr[index]=arr[i];
            index++;
            }
        return newArr;
        }
}
